'use strict';

function compute_chain_median(collection) {
  let arr=collection.split("->");
  console.log(arr);
  let s1=arr.map(function(x){
    return Number(x);
});
   console.log(s1);
   var ab;
   var answer;

// for(let item of s1){
 
// var a=s1.reduce( function (total,item){
//   return total + item;}
//   ,0);
// }
  function sortNumber(a,b){
           return a-b;
   }
     ab=s1.sort(sortNumber);
     console.log(ab);
     var i=ab.length/2;
  if(ab.length%2==0){
     answer=(ab[i]+ab[i-1])/2;
  }else{
        answer=ab[ parseInt(ab.length/2)];
  }
    console.log(answer); 
return answer; //在这里写入代码
}

module.exports = compute_chain_median;
